tdbSettings  = {
    "host":"meeting.xmgkfw.com",
    "port":42036 ,
    "token":"Basic cm9vdDpoaHVjMTExNQ==",
    "db":"pcs2023"
}
import  requests


class TDB:
    def __init__(self):
        self.tdbSettings = {}
    def write2TDB(self, datapointStr, rp=""):
        try:
            host = self.tdbSettings['host']
            port = self.tdbSettings['port']
            token = self.tdbSettings['token']
            db = self.tdbSettings['db']
            headers = {
                "Authorization": token,
                'Content-Type': 'application/json',
            }
            influxdb_url = "http://" + host + ":" + str(port) + '/write?db=' + db
            if rp != '':
                influxdb_url = influxdb_url + '&rp=rePolicy_1h'
            resp = requests.post(url=influxdb_url, headers=headers, data=datapointStr)
            #print('save to tdb:', resp)
        except Exception as er:
            print(er)

tdb =TDB()
tdb.tdbSettings = tdbSettings